*global user "diegove"
global user "diegove"

/** do que junta las bases*/
global dirdata "C:\Users\\$user\Dropbox\CCT BJP\data"
global dir1  "$dirdata\Final data"
global dir2  "$dirdata\Results\graphs"
global dirraw "$dirdata\Raw data EH 2005-2009"
global geodata "C:\Users\\$user\\Dropbox\Bolivia Data Lab\Data\Working data\Raw data\Other\geo_data\municipalities"

use "$dirraw\Municipalities2001.dta", clear
keep municipio fpc2005

rename municipio cod_secc

merge m:1 cod_secc using "$geodata\municipio_final", force
duplicates drop

bys cod_sec: gen aux=_N
bys cod_secc: egen aux2=max(fpc2005)
drop if aux!=1 & fpc2005!=aux2
drop aux aux2

format %9.0f fpc2005
spmap fpc2005 using "$geodata\coord_mun", id(id) ndfcolor(white) fcolor(Blues) legend(label(1 "N.A.") size(vsmall) position(2)) legtitle("Financial Branches per 100K inhabitants 2005")  clnumber(3)

graph export "$dir2\Appendix_Branches_map.pdf", as(pdf) replace
